package com.zx.idc.backend.gui.sys;


import com.zx.idc.backend.gui.common.BaseApi;
import com.zx.idc.backend.gui.common.Result;
import com.zx.idc.backend.gui.shiro.TokenManagerUtil;
import com.zx.idc.ds.sys.entity.SysMenu;
import com.zx.idc.ds.sys.service.ISysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 系统菜单管理 前端控制器
 * </p>
 *
 * @author rxliuli
 * @since 2019-01-31
 */
@RestController
@RequestMapping("/api/sysMenu")
public class SysMenuController extends BaseApi {
    @Autowired
    private ISysMenuService sysMenuService;
    @Autowired
    private TokenManagerUtil tokenManagerUtil;

    @GetMapping("/load-sys-menu-list")
    public Result<List<SysMenu>> loadSysMenuList() {
        return success(sysMenuService.loadSysMenuList(tokenManagerUtil.getCurrentUser().getId()));
    }

    @GetMapping("/get-parent-path")
    public Result<List<SysMenu>> getParentPath(@RequestParam("path") String path) {
        return success(sysMenuService.getParentPath(path));
    }
}

